/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Main;

import static com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type.String;
import java.util.ArrayList;
import java.util.HashMap;
import javax.swing.AbstractListModel;
import javax.swing.JOptionPane;
import javax.swing.ListModel;
import javax.swing.text.html.parser.DTDConstants;

/**
 *
 * @author jerry
 */
public class DomainListMain extends javax.swing.JFrame {

    public StartMain SMain;

    /**
     * Creates new form DomainListMain
     *
     * @param s_main
     */
    public DomainListMain(StartMain s_main) {
        SMain = s_main;
        initComponents();
        //设置居中
        this.setLocationRelativeTo(null);
        FormatGetDomainList();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        domain_list = new javax.swing.JList<>();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jLabel1.setText("域名选择:");

        domain_list.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                domain_listValueChanged(evt);
            }
        });
        jScrollPane1.setViewportView(domain_list);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 388, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 237, Short.MAX_VALUE)
                .addGap(35, 35, 35))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * 监听选择改变事件
     *
     * @param evt
     */
    private void domain_listValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_domain_listValueChanged
        // TODO add your handling code here:
        if (evt.getValueIsAdjusting()) {
            String new_domain = domain_list.getSelectedValue();
            SMain.info_use_domain.setText(new_domain);
            SMain.Auto.WebDoMain = new_domain;
            this.dispose();
            JOptionPane.showMessageDialog(null, "修改链接域名完毕!");
        }


    }//GEN-LAST:event_domain_listValueChanged

    /**
     * 刷新域名列表到界面 根据不同的网站列出不同的域名列表
     */
    private void FormatGetDomainList() {
        String web_tag = SMain.game_config.helper.GetConfKey("web_tag");

        String[] hhgj_domain = new String[20];
        String[] wnsr_domain = new String[20];

        //环球国际域名列表
        hhgj_domain[0] = ("hhgj8800.com");
        hhgj_domain[1] = ("hhgj8811.com");
        hhgj_domain[2] = ("hhgj8822.com");
        hhgj_domain[3] = ("hhgj8833.com");
        hhgj_domain[4] = ("hhgj8844.com");
        hhgj_domain[5] = ("hui0188.com");
        hhgj_domain[6] = ("hui0288.com");
        hhgj_domain[7] = ("hui0388.com");
        hhgj_domain[8] = ("hui0488.com");
        hhgj_domain[9] = ("hui0588.com");

        //威尼斯人链接
        wnsr_domain[0] = ("wnsr982.com");
        wnsr_domain[1] = ("wnsr983.com");
        wnsr_domain[2] = ("wnsr984.com");
        wnsr_domain[3] = ("wnsr985.com");
        wnsr_domain[4] = ("wnsr986.com");

        switch (web_tag) {
            case "HHGJ":
                domain_list.setListData(hhgj_domain);
                break;
            case "WNSR":
                domain_list.setListData(wnsr_domain);
                break;
        }

    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(DomainListMain.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(DomainListMain.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(DomainListMain.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(DomainListMain.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
//        java.awt.EventQueue.invokeLater(new Runnable() {
//            public void run() {
//                new DomainListMain().setVisible(true);
//            }
//        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JList<String> domain_list;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables
}
